package com.example.interview.sc;

import cn.hutool.core.util.HashUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson.JSON;
import com.example.interview.bean.vo.City;
import com.example.interview.bean.vo.Name;
import org.springframework.stereotype.Service;

/**
 * @author ：superdyf
 * @date ：Created in 2021/10/8 15:35
 * @description：
 * @modified By：
 */
@Service
public class CloneCode implements Code{
    @Override
    public void play() {
        City c=new City();
        Name n=new Name();
        n.setId(HashUtil.rsHash(IdUtil.simpleUUID()));
        n.setName(RandomUtil.randomString(8));
        c.setName(n);
        c.setCityId(HashUtil.rsHash(IdUtil.simpleUUID()));
        System.out.println(c+":"+c.getName()+":"+Integer.toUnsignedLong(c.hashCode())+":"+ JSON.toJSON(c));
        try {
            City e =c.clone();
            System.out.println(e+":"+Integer.toHexString(e.hashCode())+":"+Integer.toUnsignedLong(e.hashCode())+":"+e.getName()+":"+JSON.toJSON(e));
        } catch (CloneNotSupportedException cloneNotSupportedException) {
            cloneNotSupportedException.printStackTrace();
        }
    }
}
